ds: clean up main function (now _seems_ to be doing the right thing)