Public API changes and code cleanup

Just the first stage of a small code cleanup. I'm trying to be somewhat conservative as to what I edit to prevent any bugs from being added. I didn't change any API's (that I know of) other than documenting them.