cleanup, improved logging