Set the standalone flag before using it

This reorders imports and delays them after the args are processed.
Merge remote-tracking branch 'chiiph/bug/set_standalone_properly' into develop