Removed unused includes for OpenSSL.
Better test for stream state.
Renamed TYPE_BOOL to avoid name collision on MacOS.