Better database model and improvements to the index template