Improve error handling in transfering