Sets, Lists, Refs and Maps of imported types work now. This PR also factors some of codegen.go into a separate package, to slim down that file a bit. Towards issue #294