New pivot routine

This pull routine is better than the existing static value, as well as simpler than the version in the javascript implementation. Simple test case included.