Add factory method. Enhance Resource and Reference.

Three non-compiling profiles (sub-profiles of other resources) were removed, they shouldn't have made it into the last commit.