Adding the templates to code, adding in the handling of x and y