remove nested functions finally! (fixes clang and segfault under certain vsns of gcc)