Fix string encoding problem reported by coverity
Remove dead code
Fix equality check using != on objects

Cleanup in the code, removing dead code