Switch to compile against 3.1.0 and fix some NPE bugs in open