added a bunch of logging, also fixed switch :P