Adds map and fixes some bugs.