Code tidy
Fix a few warnings and remove some dead code