Various fixes to types, tests