Recode to clean up stuff and add support for any x*x size.