Add logging, better error handling.