it sprawled for three miles along the river and back again into the castle and was a noisy , busy place filled with a warren of passages and rooms , with small factories , schools and shops mixed in with family rooms , tiny roof gardens and even a theater .