Better window/chat management (fixes #281)

Fixes memory related issues (especially dealing with several conversations windows). See issue #281