Added clang specific compiler warning suppression.
Fixed static library compilation, using -fPIC now to allow linking
to dynamic lib.
Fixed various memory leaks, allocation size issues and API misuse
warnings shown by clang as well as some compiler warnings.