Fully working program. Now time to refactor.