repair some bugs + simplify

any idea what to do? ;)