Improve baseDir and port type handling