Fix path to functions file.
Improve inline documentation.
Fix textdomains.
Initial tidy-up of functions file.