Fixed some compiler warnings, mainly involving unchecked casts