Switch handlers from std::vector to std::map, add a max handler count, a...

...nd return an error if too many handlers exist.