Move initialization methods into main.

As well as other cleanup like deleting unused variables and includes.