As Twitter moves closer to preparing for its initial public offering, the social media giant's top legal defender is stepping down after serving four years as the company's general counsel.

Alexander Macgillivray, Twitter's general counsel and chief navigator of its complex digital First Amendment issues, is departing the company and has been replaced by Vijaya Gadde, who previously served as Twitter's legal director for corporate and international issues.

Some sources say that Macgillivray's tense relationship with Twitter CEO Dick Costolo could have contributed to his decision to leave. Macgillivray said he will remain close to Twitter during the management transition, and plans to “dial back” his day-to-day involvement with Twitter.