funcs.js code cleanup