split out the cache code
fix bug for end-record markers in GetFields