Fixes a bunch of bugs, moves raw code forward