Fix two-phase name lookup problem detected by clang. Tests now passing on Mac OS for both clang and gcc.