Upstream some shadow enhancements

Upstreaming some local shadow enhancements from various local projects.