Made some formatting changes, some untested.