fix session bug where too much mem was used