fix @endforeach, small namespace changes