fixed many stupid bugs