Fix #692 and #526