An Extension Theorem From Connected Sets, and Homogenization In General Periodic Domains