Refactor, cleanup, added form controls.

Refactor, cleanup, added form controls.