Added changes for proper replacement and swapping of cache blocks.