Removing a lot of dead code
Made some changes to clear_cached_values