lots of changes, resolving getopt problems