diff --git a/common-session.c b/common-session.c
index 02eeaaed42f3dd4b1432a9539069a09746af1f1a..49dd8f8074dce3d5c4164f8897f75aea06cec8a0 100644
--- a/common-session.c
+++ b/common-session.c
@@ -433,12 +433,13 @@ static long select_timeout() {
 	long ret = LONG_MAX;
 	if (KEX_REKEY_TIMEOUT > 0)
 		ret = MIN(KEX_REKEY_TIMEOUT, ret);
-	if (AUTH_TIMEOUT > 0)
+	/* AUTH_TIMEOUT is only relevant before authdone */
+	if (sess.authstate.authdone != 1 && AUTH_TIMEOUT > 0)
 		ret = MIN(AUTH_TIMEOUT, ret);
 	if (opts.keepalive_secs > 0)
 		ret = MIN(opts.keepalive_secs, ret);
-    if (opts.idle_timeout_secs > 0)
-        ret = MIN(opts.idle_timeout_secs, ret);
+	if (opts.idle_timeout_secs > 0)
+		ret = MIN(opts.idle_timeout_secs, ret);
 	return ret;
 }
 
diff --git a/packet.c b/packet.c
index b624c27eb5a81fe9a126d57431c3cc691d024d20..8f7aa389be90038828457ba0d503d335844bb95b 100644
--- a/packet.c
+++ b/packet.c
@@ -87,12 +87,12 @@ void write_packet() {
 	if (written < 0) {
 		if (errno == EINTR) {
 			m_free(iov);
-			TRACE2(("leave writepacket: EINTR"))
+			TRACE2(("leave write_packet: EINTR"))
 			return;
 		} else {
 			dropbear_exit("Error writing");
 		}
-	} 
+	}
 
 	if (written == 0) {
 		ses.remoteclosed();
diff --git a/process-packet.c b/process-packet.c
index 1c2ca7be4e33cbfe0187a82e17f527ff76831d53..3659cc0f77aae7c4c0132d3b60f671d93690bf89 100644
--- a/process-packet.c
+++ b/process-packet.c
@@ -52,7 +52,7 @@ void process_packet() {
 
 	ses.lastpacket = type;
 
-    ses.last_packet_time = time(NULL);
+	ses.last_packet_time = time(NULL);
 
 	/* These packets we can receive at any time */
 	switch(type) {