Misc static analysis fixes