Added better logging and changed the cache stuff