move BASEDIR to the top of the file