Refactoring.
Should fix #306.
FIxes session logic
Merge pull request #312 from angathorion/refactor

Refactoring and small fix
Merge pull request #314 from angathorion/session-logic-fix

Session now only keeps window size