Fixing some glaring bugs pointed to by the wonderfull typechecker