Fixed bug regarding encoding to hex, simplified code. Cut down on useless code.