Added new features, fixed bugs, optimized code