Various fixes, removing of old and unnecessary code.

Will comment on some of the changes.
This should no longer be necessary as it is a cache now.