Coverity fixes

fixed defects from 1st run in Coverity scanner
- mismatched delete[]
- memory leaks, missing destructor
- improper bit shifts
- NULL referencing problems
- etc.