Pretty large commonization/refactor for 0.4
update for 0.4