Removed unnecessary base64 encryption and organised code a bit better.