First commit of working code. Needs cleanup.