Adding session checking to potentially fix bug #4.