Fixed some problems with unsigned, some blatant error with resizing vectors that I could've sworn I'd seen before, performed static analysis.
Formatted to make a little neater.