fix homeline/mention bug, mv template function to model definition