More debug logging, fix for transfer_to_env