Added changes by Elliott to extract script