Code improvements and future proofing