Added initial code for caching when decoding