Fixed memory leak caused by misuse of sessions