fixed compiler warnings
more performance improvements
refactoring for more performance improvements