3.1 branch & compatibility fixes