Minor C code refactors