add commandline options, some tweaks to joining code