cleanup some copypasta from libcrange stuff