many changes to formatting, and multiple bug fixes everywhere