optimized filling of ghost layers