Fix darwin check and option parsing

Change-Id: I294e27ea9de51a02eeae079e913d78c032e1cdd4