How Medieval Towns Paved the Way for Capitalism