Fixing compiler warnings

This branch fixes all compiler warnings for GCC 4.9 and Clang 3.5, and enables -Werror build flag.