Optimized and corrected a few bugs!
More optimizations!
Merge branch 'optimization'