fixed enumerability of models and refactored model_flatter