Code comenting and tidyup
More sql, api changes + sessions