fix bugs; templating issues