add functions/db in installer, reorganize scripts loading, fix #2220