Some code reorganizations