Catch potential index errors.
Merge pull request #11 from cybersimon/master

Catch index errors