Cleaned some allocated resources by adding delete statements I have initially forgotten.