added metadata compilation and caching to C layer