more code documentation and clean up