This fixes a buffer overflow and avoids unnecessary casts and other cleanup thorough the code. --HG-- extra : convert_revision : 4b389251cfb76b28028967cd60c409fe94f6c85e
--HG-- extra : convert_revision : 87473fb499c42deaf0285f5559dc1cd8d67ab436