As per @marmarek's request. Also docstrings.
Now the function returns a list of tuples, not a list of lists.