Adding callback functions when certain things happen.