A bit of typecasting for security and a clarification in comments