You can't just clear the map...you need to rebuild it.  Take a look at updateLibrary for an example.