Better error checking
Merge pull request #7 from Soulou/error_handling

Better error checking