made align allocate in the double edge into a template and cleaned up some code.