several tool bugfixes
general code enhancement