Add test and set, improved validation and debugging