Fix bugs in static cast methods