Include defuns before they're used

Ensure that defuns and local functions are defined before they are first
used.