JavaScript code styling and cleanup