Fixed a few bugs in the gendata_complex subroutine and the final section of the main routine