Refactored crypto functions and implemented handler and sender