Minor reshuffle of code to make it a little more logic.
Issue #140: take 2; thanks to NeoBoot for testing the first patch.
Issue #143: fixes for the Un*x run-scripts. Thanks to R.Diez for mentioning this.