Patches and compiler warnings fixes.

Fixes "drop in" replacement issue
Fixes varius compiler warning