As zero-commission stock trading app Robinhood starts preparing to IPO, an engineering investment two years in the making could accelerate its quest for profitability. Most stock broker services have to pay an external clearing house to reconcile trades between buyers and sellers. Now with 6 million accounts up from 4 million just 5 months ago, that added up to a huge cost for Robinhood since it doesn’t demand a trading fee like the $7 to $10 that incumbent competitors E*Trade and Scottrade charge. Relying on outside clearing also introduced bottlenecks around its innovation and user sign ups, limiting onboarding to business hours.

But today Robinhood will start migrating accounts to its new in-house clearing service over the next few months. That will save it from paying clearing fees on stock, option, ETF and cryptocurrency trades. In turn, Robinhood is eliminating or reducing some of its edge case fees: $10 broker assisted trades, $10 restricted accounts, $50 voluntary corporate actions and $30 worthless securities processing will all now be free. Robinhood is meanwhile cutting its margin on fees passed on by banks or FedEx, so ACH reversal fees will drop from $30 to $9, overnight check delivery from $35 to $20 and overnight mail from $35 to $20.

“What’s really interesting is that this is the only clearing system built from scratch on modern technology in at least the last decade,” Robinhood co-founder and co-CEO Vlad Tenev tells me. Most clearing services ran mainframes and terminal-based UIs that aren’t built for the pace of startup innovation. Going in-house “allows us to vertically integrate our business so we won’t have to depend on third-parties for foundational aspects. It’s a huge investment in the future of Robinhood that will massively impact our customers and their experience, but also help us out on building the kind of business we want to build.”

There’s a ton of pressure on Robinhood right now since it’s raised $539 million to date, including a $363 million Series D in May at a jaw-dropping $5.6 billion valuation just a year after raising at $1.3 billion. Currently Robinhood earns revenue from interest on money kept in Robinhood accounts, selling order flow to exchanges that want more liquidity, and its Robinhood Gold subscriptions, where users pay $10 to $200 per month to borrow $2,000 to $50,000 in credit to trade on margin. Last month at TechCrunch Disrupt, Robinhood’s other co-CEO Baiju Bhatt told me the startup is now actively working to hire a CFO to get its business ready to IPO.

Whoever that CFO is will have an easier job thanks to Christine Hall, Robinhood’s Product Lead for Clearing. After stints at Google and Udacity, she was hired two years to navigate the regulatory and engineering challenges of spinning up Robinhood Clearing. She explains that “Clearing is just a fancy word for making sure that when the user places a trade, the price and number of shares matches what the other side wants to give away. In the less than 1 percent chance of error, the clearing firm makes sure everyone is on the same page prior to settlement.

Forming the Robinhood Securities entity, Hall scored the startup the green light from FINRA, the DTCC and the OCC. She also recruited Chuck Tennant, who’d previously run clearing firms and would grow a 70-person team for the project at Robinhood’s Orlando office. They allow Robinhood to clear, settle (exchanging the dollars and shares) and ensure custody (keeping records of asset movements) of trades.

“It gives us massive cost savings, but since we’re no longer depending on a third-party, we basically control our destiny,” Tenev says. No more waiting for clearing houses to adapt to its new products. And no more waiting the whole weekend for account approval as Robinhood can now approve accounts 24/7. These little improvements are critical to Robinhood staying ahead of the pack of big banks like Charles Schwab that are lowering their fees to compete, as well as other startups offering mobile trading. The launch could also blossom into a whole new business for Robinhood if it’s willing to take on clearing for other brokers, including fintech apps like Titan.

Clearing comes with additional risk. Regulatory scrutiny is high, and the more Robinhood brings in-house, the more security work it must do. A breach could break the brand of user trust it’s been building. Yet if successful, the launch equips Robinhood for an ambitious future beyond playing the markets. “The mission of the company has expanded a lot. It used to be all about stock trading. But if you look at Robinhood five years from now, it’s about being best-in-class for all of our customers’ financial needs,” Tenev concludes. “You should be able to get everything from Robinhood that you could get from walking into your local bank.” That’s a vision worthy of the startup’s epic valuation.