Fixes for problems found by Armageddon Monkey