pk2pk has been integrated into PKHeX and has since received multiple updates to handle certain edge cases.
It's not incredibly optimized but emulates the transfer 100%.
I like to have well documented (commented) code, and pk2pk.cs is pretty extensively commented to document all the changes a Pokémon would undergo transferring across 3->4, 4->5, and 5->6.