reduce the public interface and header dependencies, and move most functions to implementation files