cleanups: private functions and logging