fix javascript errors and remove some newlines for visibility