I recall reading somewhere (can't find it for beans now) that the Windows kernel was a huge mess codewise since many of the original developers have moved on and poor to nonexistent documentation was left, meaning that the modern employees had to basically reverse engineer a lot of the code.
Take this with a grain of salt, of course.