Fixed indenting, added loop checking

Working out the clusterfuck that is looping:
Store beginnings in a stack, endings in a queue for easy pushing
and popping. Nested loops will be a bit of a problem with just the
stack and queue, hence loopDepth. Probably going to need arrays.