Fixed API compatibility issues and simplified memset call.