Revert "Bug fixes"

This reverts commit 590cf74df493e22e597d39c12c3b21ddc9d59c8a.