Fix instance variable issues and format regex