Improve errors and validation