Added some code to submit less duplicate API calls, makes the program run smoother.