Several smaller bugfixes