Added comments.
Added optional max number of entries parameter.