Simplified the code. Removed the map of routines.