minor bugfixes and better comments