Fix vector overwrite(probably?) , do general memory and cleanup