margin metrics and model refactoring