Added logging functions to clean up code.