Smarter window management
Fixing memory issues.
Merge pull request #351 from FredericJacobs/fix-memory

Better window/chat management (fixes #281)