Fixed hash dereferencing in two places and proper end of files