added much database related / contact fetching logic. Addresses #6.