Main functionality implemented.