fixed if structuring, still need to add some details and obviously beef up the test cases but for now it passes 10 of the most simple cases; also did some other shit i forgot about
add missing files