fixed 'adding waypoint' bug.
code cleanup.