fixed logic for setting cache value
removed old debug code
removed more fugly pragmas