Improved handlers' state managing logic.