Added set function. Fixed memory error.