several fixes up to get JS code working.