beads.cc debug version, template.cc for future problems