Adding docstrings and error check to fix #471
Merge pull request #475 from darribas/fix471

Adding docstrings and error check to fix #471