Code clarity changes to xray.js
More small code quality fixes to xray.js