Use int instead of shorts, remove unused casts