Formatting and logging

Fix some formatting and introduce more logging.