Add a bit more exception handling