Updated cachesim code