Update main.pas

Life 9.6
Some bugs fixed.