formatting and some various other changes suggested by @moben