Bugfix, code comments, refactoring