Added optimizations and new set module