Some changes and basic error handling