i'll merge this revision by hand since its a mix of cleanup and 2.x specifics