What is the function of the Spanning Tree Protocol (STP), and how does Rapid STP (RSTP) improve network convergence?