Fixed some bugs relating to names containing underscores etc.