Some fixes for eof handling in Memory