Some changes to internal logic