Change floats to ints recursively on env encoding

Fixes #6246