Improved base path handling.