Apparatus (20) is provided for implantation into a body of a subject, including isolated functional cells (28). At least one first barrier (22) having a first molecular weight cutoff is disposed with respect to the functional cells so as to protect the functional cells from components disposed within body fluid of the subject having molecular weights higher than the first cutoff. Photosynthetic elements (26) are disposed with respect to the functional cells so as to provide oxygen thereto. At least one second barrier (24) has a second molecular weight cutoff that is lower than the first cutoff. The second barrier is disposed with respect to the photosynthetic elements so as to protect the photosynthetic elements from components disposed within the body fluid of the subject having molecular weights higher than the second cutoff. Other embodiments are also described.