A bunch of minor changes and bugfixes