Bugfixes and more comments on code