merged with bugfix from mapjs