Long-standing bug in session.c fixed