Revert "Bug fixes"

This reverts commit 8a2cd64234092170d920c138b01658cdc4c6b0e6.