Generic handler refactoring

While writing the new handler for PhyloStylotastic (www.evoio.org/wiki/PhyloStyloTastic, to be included in a separate pull request), I refactored a massive amount of code to make the Namespace handling more generic and able to fail more gracefully in more conditions. I also moved a lot of repetitive code to the most basal possible class and did some speed improvements.