Improve handling of linear algebra issues; add options to fine tune iterations