Works but ugly

At the moment this is some very convoluted code. I really need to make sure this gets cleaned up and that it no longer requires a hard coded IP. Everything should be self sufficient.