Manipulating and protecting entanglement by means of spin environments