added metadata support and many tests to accompany