4.2-051: Adopted changes to javascript code from 4.2-51