Fixed Entity writing, input and output now match.