Decouple code in preparation for implementing applet and sidebar versions