Revert "Multiple improvements and fixes"

This reverts commit 85c307601d7ef7e5c7613c003cd0f3a406013271.