Fix locking issue, add locking to GUI