Proper error codes. Closes #182.