Refactoring code.
and add Base64 encoding.