Holy crap that's a long function to allocate some bytes!