More main implementation