Refactored code and added version 2.0 features.