Const correction and log to standard error.
Formatting fixes.