Fixed error in the memory management system

New pages are also considered for the freeing of buffers.