ported to git, tested still works