a big cleanup
i have split the bugs into several files so that they are easier to control