Major revisions. Refactoring code for better support and error handling.