Fix the most obvious problems

Lots of creepy code remains