Added logging and debugging information.