funcs.js code cleanup

This code is tested in my dev environment and should not break things or cause any issues.