added last fixes and changes from previous non-git version