Fix bugs that crept in when abstracting the functions in OO JS file.