fixed so that error messages are properly logged with stack traces