moving from getopt to optparse, and general cleanup

All of the old options are preserved.