Code refractored

- refractored. 
- fixed some newly introduced bugs
- fixed zooming problem due to deep copy