Moved two functions to top of source to avoid requiring function signature.