improved base path resolution