Bugfixes, more code separation