A new noncolonial constitution came into effect in 2007 , and the European Court of First Instance recognized Gibraltar 's right to regulate its own tax regime in December 2008 , but the UK retains responsibility for defense , foreign relations , internal security , and financial stability .