fixed many bugs