backported fixes and an added feature