fix issues from cppcheck

unitialized variables
possible memory leaks 
unused code
also fix some remaining tabs