diff --git a/cas_auth/start.php b/cas_auth/start.php
index 160228c926e1bb881c85d5dc3012d013804ddf37..88191e2b0fe658530f6fcb914aaa4af70d93ff00 100644
--- a/cas_auth/start.php
+++ b/cas_auth/start.php
@@ -119,12 +119,11 @@
 					system_message(elgg_echo('loginok'));
 					$cas_user = str_replace('-','_',$cas_user);
 					
-					//user is logged in now, this is the last step - forward based on whether they have logged in before
-					$lastlogin_date = $_SESSION['user']->last_login;
-            		if (!$lastlogin_date) {
+					//user is logged in now, this is the last step - forward based on whether they have logged in before 
+            		if (!$_SESSION['user']->last_login)
             			forward('mod/profile/edit.php?firstlogin=yes');
-            		}
-            		forward("pg/profile/unl_" . $cas_user);
+            		else
+            			forward("pg/profile/unl_" . $cas_user);
 				} else {
 					register_error(elgg_echo('loginerror'));
 				}
@@ -243,7 +242,6 @@
 		//Replace the hyphen in a student's name with an underscore
 		$username = str_replace('-','_',$username);
 
-		
 		if ($user = get_user_by_username($username)) {
 			// User exists, login            	        
 			return login($user);
diff --git a/cas_auth/views/default/account/forms/login.php b/cas_auth/views/default/account/forms/login.php
index d71c56d23e9cb34a80579c25bbd7c60a9704ade8..acb4a00aa998d0c705adef4e56c0d9586ae0577e 100644
--- a/cas_auth/views/default/account/forms/login.php
+++ b/cas_auth/views/default/account/forms/login.php
@@ -24,7 +24,7 @@
 	//<input name=\"username\" type=\"text\" class="general-textarea" /></label>
 ?>
 	
-<div id="login" class="loginPage">
+	<div id="login" class="loginPage">
 		<div class="two_col left">
 			<h2 class="sec_main">Students, Faculty, Staff</h2>
 			
diff --git a/cas_auth/views/default/actions/getemail.php b/cas_auth/views/default/actions/getemail.php
index 8847eefccd53736b519d19ab68eefa940c8b2560..49147433620421073b2a20a4cb024dfc5564caff 100644
--- a/cas_auth/views/default/actions/getemail.php
+++ b/cas_auth/views/default/actions/getemail.php
@@ -10,44 +10,28 @@
 	 * @copyright Curverider Ltd 2008-2009
 	 * @link http://elgg.org/
 	 */
-
-//	require_once(dirname(dirname(__FILE__)) . "/engine/start.php");
+ 
 	global $CONFIG;
 	
-//	action_gatekeeper();
-
-
-	// Get variables
-
-		$email = get_input('email');
-	//	var_dump($email);
-	
-		$email = sanitise_string($email);
-	//	var_dump($email);
+	action_gatekeeper();
+ 
+	$email = get_input('email');
+	$email = sanitise_string($email);
 
-		if (is_email_address($email))
-		{
-			if (!get_user_by_email($email))
-			{
-				forward('?loginwith=UNLlogin&email=' . $email);
-			}
-			else
-			{
-				register_error(elgg_echo("Sorry, that email has already been registered.  Please try again."));
-			}
+	if (is_email_address($email)) {
+		if (!get_user_by_email($email)) {
+			forward('?loginwith=UNLlogin&email=' . $email);
+		} else {
+			register_error(elgg_echo("Sorry, that email has already been registered.  Please try again."));
 		}
-		else
-		{
-			register_error(elgg_echo("Sorry, that is not a complete email address.  Please try again."));
-		}
-	
-		
+	} else {
+		register_error(elgg_echo("Sorry, that is not a complete email address.  Please try again."));
+	}
 		
-			
-		$qs = explode('?',$_SERVER['HTTP_REFERER']);
-		$qs = $qs[0];
-		$qs .= "?e=" . urlencode($email);
-		
-		forward($CONFIG->url . 'mod/cas_auth/views/default/account/getemail.php?e=' . urlencode($email));
+	$qs = explode('?',$_SERVER['HTTP_REFERER']);
+	$qs = $qs[0];
+	$qs .= "?e=" . urlencode($email);
+	
+	forward($CONFIG->url . 'mod/cas_auth/views/default/account/getemail.php?e=' . urlencode($email));
 
 ?>
\ No newline at end of file