Add error checking for invalid operators, and better error message for invalid values