Many changes to allow GetSessionId to work [WIP]