Enabled caching of retreived documents
Fixed bugs related to caching and new data structures