Move common code from common primitives to core package
Currently there are some useful common code in utils in common primitives. That all should probably be moved to the core package (something to utils there, something as methods on the metadata class).