Fix bugs in shared js