Fixed bugs and updated the template block