Re-factoring of the meta data service

Please review and merge