move headers to where they ought to be
fix visibility of private functions