Redesigned and fixed many bugs