fixed many bugs.