several big and small changes, but not all bugs catched yet