Integrate functionlib.sh to the webgui and make some improvements