Fix some Javascript and SQL linkage