Revert "applied fixes and some changes, see desc."

This reverts commit 3308d33dfd141d21f045af56fc919e24f548c431.
Revert "Revert "applied fixes and some changes, see desc.""

This reverts commit 92756a748ff75a8eae180f2758a6c0a4dba500dd.