Major changes to the program, and possible some new bugs, needs more testing