Major cleanup of JS sample code.