Adding robustness to crashing with warning message printing in several places