global handlers code cleanup & fixes