Main functionality.