Clean up of types, casting etc.; further testing of inductive types.