Optimize clipping of data
Removed debug messages
fixed merge conflict