Numerous little fixes to make previous commits actually finish test.