anvil: more refactoring