Avoid closures, move planning code to _plan() and layer G-code generation to Slic3r::GCode::Layer