when were medieval towns built