Further cleanup, bugfixes