(QENG-1225) Minor code cleanup and reorganization.

Signed-off-by: Wayne Warren <waynr@sdf.org>
(QENG-1225) Swap out recursive method calls with while loops.

Signed-off-by: Wayne Warren <waynr@sdf.org>