fixed basic bugs and deepcopy bottleneck