Massive changes to the loop.

I have cleaned up the loop, moved them and seperated out the logic.
Also fixed responsive issues and updated the doucumentation.