lots of formatting changes as well bug fixes!