Prefix local functions with an underscore; simplify some variable declarations