Fix a few compiler warnings

Just a few typical warnings:
- storing int to char
- storing int to unsigned short
- assignment within conditional expression