Moved try-finally clause that sets the current session to null to make sure we have a session when jsonpatches are generated.
Merge branch 'session_ended_bug' into develop