Reorganize the code in main.go a bit.