Redesigning values logging.

Removing code duplication: parameter and return values use same code.
Fixing bug with logging byte array return value.