Fix bugs with virtual memory