Add logging and do some minor formatting changes.