Tested and fixed many bugs.