Added better error handling, updated README and added an example script.