Change how case statements are being handles...plus couple of small bugfixes