Several bugs fixed, optimization, and improvement.