add documentation and minor clean-up