small bugfixes, program fully tested