Fixed bug where the wrong class would be saved in cache