Clean up JavaScript code