git rid of silly unchecked casts
Solution to #402