small optim
various small fixes