Cleaned up map code a bit.