Code cleanup. Setting resource state through specific functions