Changed build system to cmake, made error handling more verbose, fixed many warnings, and added exception handling.