MAIN PROGRAM ROUTINE + A LOT OF IMPORTANT AND UNIMPORTANT CHANGES