OOP Refactoring + session support
some improvements