refactor some helper functions for better naming add _child_* helper functions fix constructing constraints