half baked #615
#615 half baked
#615 mostly done, need to resolve duplicate name case, test other corner cases and do regression test