Fixed serveral stupid bugs