Introduce common-exceptions.[ch]
Use exceptions and cleanups