Fix model bugs