debuged and fixed some unit-generator code