Refactor array generation code for later integration of struct generation code