Overhaul cache, add main and webimage classes