Tidy warnings and unused code