Better refs and modal fix