Some fixes in program structure + useful functions were added