redo type promotion logic, fix bugs