clean up the caching code a tiny bit

add a command line flag to turn caching on or off (off by default)