Move all the casting to __main__