Some stupid bugs fixed