fixed many bugs!