Added fixes for 64bit code and ability to control the CACHE_LIMIT without branching the code.