Big refactor

As a learning experiment, I kept everything in `main.go`, this attempts to simplify the chaos.