several improvements ad debug