Make use of functions.length() more consistently