Fix null map object error.
Migrated the majority of the map code to the map fragment.