Actually return the return_code when optimizing.

Fixes #396