Error cases and cleanup