various fixes to render function