Bugfixes/cleanup