Clean up JS code