Fixing some gotchas found in testing