Revert "fixes error propagation in optimize.c" due to failing master

This is just an attempt, let it go green first.