Fixed compiler warnings.

- Fixed compiler warnings related to mis-ordered class attributes,
  unchecked return values, and some integer signed/unsigned comparisons.
- Replaced all logging macros by calls to proper static methods.