remerged from latest version from jake