Bugfixes, refactoring, comments.