Move session handling to separate class, create types.h for type definitions, minor cleanups

Change-Id: If79209d2480f5bc47705b03b1b3e43a31839ac9a