move chain stuff under handlers, template registration under templates