Small bugfixes for refactoring