vendored main script