Refactor the initial arguments parsing.

Rename variables and comment algorithm so that it can be understood more easily.

Signed-off-by: OwenPatey <owen_patey@hotmail.com>