Various minor bugfixes