code formatting cleanup and some documentation