added comments, small bugfixes