fixing bugs, adding lookups, foreignKeys, and system metadata helpers