indexes and some fixes in template