うちに vs 間に — both mean 'while', what's the actual difference?

I keep mixing these up. My textbook example was 子供が寝ているうちに掃除をした (cleaned while the kid was sleeping) but I've also seen 間に used the same way. Is うちに more about 'before the window closes' and 間に just neutral duration?
Post
沐學 Mizuru