Some fixes for Main