Massive dump of pre existing code.

Working on this for a while before the move to github.