Port back various changes from http://paperjs.org