Split the main part into its own source file.

Signed-off-by: Thiago Farina <tfarina@chromium.org>