some bug fixes

some bog fixes, stupid mistakes corrected, ect.