Improvements to foldr example