Large refactor using maps, better extends

Most of this is a straight refactor, generated output is the same however there are a few additional extends and surgical classes.
The only thing I would mention is that it took me awhile to realize that this piece was here. I was wondering how it was getting all the options to extend.

Perhaps moving this to the top, or at least having a comment at the top that references this would help.

Up to you - other than that this is very kick ass.