Bugfixing

Some bugfixes that hopefully are not of the "will cause bugs elsewhere"
type