Improved logging, slight cleanup.