Fixed some bugs that was making it run infinitely. Works a lot more now