CustomMetadata framework and some code optimisations.