Validation and some small fixes