Added several switches, and cleaned up some more code.