Reformat, clean some code, move up inner classes
Building main form