Remove unused code
Fix compiler warnings
Remove always-false if-blocks, make code more compact