Many fixes to get tests passing.