Fix findbug warnings and refactor the error message.