Added a cashing class, refractored the caching and html generation