Sort out failing test-case. Improve code namespace handling.
Remove enumeration for tracking state... it's easier with a simple boolean and some condition checks.