Improve performance of URLOutputStream. Closes #654.
Remove unused code