Is your function body really 600+ LOC?? If so, then I think I might have found your problem...
When people focus on the _right_ implementation for _their_ problem they often find out that best practices like DRY or abstractions don't scale well at all.