Fix warnings related to signed/unsigned.

Also for implicity casting double to int.