Huge update - added new functionality and refactored