Finished refactoring and fixed a memory bug related to the sim_data struct causing segfaults