Added the cache, regression tests, and more

Still need to finish the Rotate function – when it uses the cache it crashes. Haven't looked into it yet.