Rearrange in OOP style; now broken (trynig to use only i_main, i_context
as function parameters)