Modularity and coordination for planning and reinforcement learning