Fix minor bugs, make scope update dynamic