Do some exception handling and clean up on failure