Changes to make the code more functional, if not purely functional.