Improve log messages.
Improve comments and add missing return statement.