Fix some bugs with modal and routing.