Finally fixed bug! Problem was that I was creating pipes when I was making the pipes array. Not sure why this was an issue but is fixed now. Removed debug functions.