Added more patches to make it work on appengine