Updated to correctly handle out-of-directory builds