Cleaning up the interaction between the bg and popup scripts