Basic integration done, untested.
Woops, fixed some things