Performed some simple optimizations on the F# code, e.g., to avoid unnecessary array creations and copies.