chacha code clean up and function rename