rice: optimize some uv calculations