Fix up algorithm
Body of work
Oh, uninitialized variables