Added a very dirty caching algorithm. Speeds up my program byabout 70%.

Will clean up later.