Major refactor; wrote up code for sync of Contacts.