Made it so that the location manager will stop running when it does not need to. Also some cleanup stuff