Cleaner version of 631928207. Sets prototypes as in https://github.com/onsip/SIP.js/issues/23#issuecomment-43747712