Assorted bugfixes and small features