minor refactorings, fixed ID output