Fix logging and code cleanup

This fixes the logging and removes some unnecessary code.