Use implicit falseyness of 0
Refactor open_cb
Remove unnecessary variable
Refactor command-line runner code

`if __name__ == '__main__'` will assure that this code will not be run
if imported. Using the `registered` dictionary is maybe just personal
preference, but I think it's a little more elegant than a large if/else.
It's also slightly easier to extend, though not by much.