Improved the functions for adding a marker.