Update project settings.
Add protocol declaration.
Fix a whole bunch of leaks and warnings.