Changed main loop

There were uneccesarry commands being executed during every loop that
only need to be exectued once... moved them to the init... also I split
the init up into different functions due to personal preference