Close #21

Make a switch command, and also fix a fair number of bugs