Null pointer checks and illegal charsets checks now implemented.