Almost finished port to 1.7