Fixes for dtype casting