Custom metadata

Implementation of the functionality described in #252 

Tests:
* Unit test: 100% pass
* Harness: 100% pass
* Valgrind: ongoing while you read this :)