Renamed discover function to metadata. Added new discover function that builds the right type of resource object according to meta-data.