Added cache and fixed bugs

Fixed Bugs and added cache system