bugfixes and lots of comments