It takes a special kind of mojo to get a song just right. And a lot of the magic cooked up by One Direction on their brand-new album, Midnight Memories, was literally created after midnight, during late-night sessions with the guys on the road.

One of those sessions was captured for fans in the group's 3-D flick, "This Is Us." Directioners got to see Zayn Malik record parts of "Best Song Ever," but there's something they didn't get to see during that nighttime session.

Co-producer/songwriter Julian Bunetta revealed to MTV News what else Malik accomplished.

"So I woke him up — they had just done two shows that day. They're back on the bus; I woke him up at three in the morning or something. Zayn likes to sleep, so I had to wake him up and we just set up in the studio in the hotel room. And after we recorded 'Best Song Ever,' that was the last vocal for that."

He continued, "But what they didn't show was us recording 'You and I' after that cause I needed ad-libs on 'You and I.' If it [hadn't been] that time of night and we weren't in that moment, [because] whatever happened in that moment, was when he came with that, and he just hit that amazing high note at the end chorus. It was things like that on the fly, we had to do it, we had to go with it, and amazing stuff came out of it."

While the track initially came about after Bunetta and his collaborators, John Ryan and Jaime Scott, were chatting about their love lives, the song eventually came to focus on more than just romantic love. In the end, it also serves as ode to 1D's fans.

"We had this idea of, like, the references in the lyric [are about opposites]. When you sing 'silence and sound,' those are opposites. And 'day and night,' 'up and down'," he explained, "and we were thinking, 'OK, were they ever one thing? Before they were day and night, separate things, were they ever one relationship that wasn't [separate].' So you and I, we don't want to be separated [like that]."

But, 'You and I" was hardly the only song recorded in the dark of the night. Bunetta, who also worked with 1D on 2012's Take Me Home, shared that it was hectic to make this album but also a lot of fun.

"There were deadlines. There were boundaries because you can't just spend all night with them, at least, in the studio," he said. "They have a certain amount of time; they have an insanely busy schedule. ... Because we had deadlines, we would have to make decisions on the fly that were either gonna be the right call and be brilliant or wouldn't work out," he recalled. "And so it gave us a pressure situation and I think people who are great at whatever, they do thrive with that. I like a bit of chaos."

So, just how chaotic did it get? "It was wild: new cities, new experiences, new things. It was so fun," he said. "It was like being a kid, for me. It was like grown-up sleepovers, or something."