Bugfixes & cleanup