Backported all changes from ST3