Moved session properties and methods to session module, mve database connect to be on demand.
Reworked the API structure.