Things to perhaps consider…
General
Software Engineering
Please consider any code given here as pseudocode or illustrative only unless otherwise specified. The old Donald Knuth’s quote applies: “Beware of bugs in the above code; I have only proved it correct, not tried it.” And as I’m no Leslie Lamport, I can’t even claim to have proved it correct.