optimize few functions
Profiling done
Merging branch 'opt'