Complex sentence: He stayed there until 1847, spending his free time studying mathematics and botany while attending the university in Bern once week.
Split into simpler sentences: He stayed there until 1847, and in the meantime spent his free time studying mathematics and botany. He kept going to the university in Bern once week.