Using exeptions instead of exit, where possibe.