Better script dir detection.