Modified options parsing.

Using Jonathan Leffler example from the link below as base:
http://stackoverflow.com/questions/402377/using-getopts-in-bash-shell-script-to-get-long-and-short-command-line-options

Seems to work as my intention, but I have no idea why ;) Note that this
subsequently highly experimental.

Change-Id: Ie95dbc68032af3ead7fa913caf5dce19e925fcd5