Added missing error checking, closes #9