Cleanup, bugfixes