Revert "Bug fixes"

This reverts commit b0e10de6dcf776dc883b9b474d01db0bfb81f5dc.
Bug fixes