Added support for session management.
This way we only start a session when required.