add site_dir to config vars, and minor refactoring