the first commit will probably be wrong because I've probable misunderstood side effects grumble grumble

ok i'll revert that and cry in a corner