Removed duplicate call of main. Added more logging.