findHelix overloads integers used both as indices in a triple-nested loop and as flags for various conditions. The logical conditions should be split out as explicit flags. The loops should be refactored into functions, and the intent of this code should be described in comments.