This eliminates duplicate code, fixes some log levels, and removes unnecessary trailing newlines. Fixes #202.