some refactoring and plumbing for 1.4
swigall