Add and Edit functions

Added "Add" and "Edit" features to the map. Also cleaned up code
(remove extraneous variables. converted code to functions)