Revert "Revert "Bug fix...""

This reverts commit bf7699e407eec660e1b67d51897dfb105101a9db.