Start working towards consistent naming.
Start refactoring.

    Pull a couple of 'if' statements into their own body,
    and move to using a switch statement for the select
    loop body.
Fix it so the code works again.