Implemented publish/subscribe to improve performance.