Porting some edit utils from purcell