Cleaned up script a bit to be added to the public repo.