Fix some minor mem leaks due to metadata handling

This should even work if we ever allow more than one result per tag