Refactored map code, got sequence of events working