Background script code cleanup