Fix crash on render by borrowing hints from https://gist.github.com/NathanW2/dea3a95648279fbe160d