Some bugfixes and refactoring.