Rewrote everything, almost works...
Oops forgot to record the changes I made
Hell bug fix. Also formatting and details.