Added logging and some debugging information.