WIP: mid-rewrite of sim