394.24 Porting recent changes to G2; Re-arranged main() for compatibility