fixes for some issues

Comments has been added everywhere except FrmMain, it needs more work.
many functions  has been organized and strengthened