address re comments and resolve some small bugs
resolve merge conflicts