Refactored some of the codebase.

3 batches of the same code was added into two own functions.
This makes it easier to extend the checking of the status if it should be needed, without doing so in 3 different locations.
A function to fetch a webpage was also added, because it was just copy-pasted 3 times.