Small tidyings and bugfixes