JS code cleanup