Adding doc comments and minor cleanup.