Properly pass the error up when compiled without INVARIANTS.
Plug minor memory leak.