Final fixes to pass typechecker and privacy passes.

Still doesn't pass the borrow checker :/