Added timeout option and improve error messages

- New timeout option (defaults to 0)
- Nicer error messages if err != null