Feature/make robust

Various improvements for robustness and performance.