Bugfixing; refactoring.