Bugfixes + cleanup