Some fixes for the session code.