Refactoring.
Should fix #306.
Fixes #311.
FIxes session logic
Merge pull request #313 from lowjoel/fix-311

Fixes #311.
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