added cleanup functions and fixed a few logic errors in frame table and page table