Cleaned up function.js and fixed syncing issues