Some engine fixes