bugfixes to render.py, presumably from the last accepted PR