Documentation and minor code improvement