Getting rid of unchecked warnings for casts