Some refactoring, removed logging, created session interface