Added more comments to the implementation.