Working on fixing memory corruption