Cleanup memory map iteration

Just some small fixes to use types better.