some fixes, debugging aid added, still some bug