Cleanups, bugfixes