Small cleanup of code.
Split loadClassMetadata in separate functions.