removed global for comindex, added debugging routines, command line options