memory: overflow fix and minor changes

The unsigned int fix in the loop fixed a crash in FS-UAE a while ago (where i << 16 overflowed and caused invalid memory accesses). The other changes are minor const and logging fixes, and removal of a couple of unused variables.