more incremental improvements
merge manually, somewhat messy, oh well