Refactor: Eliminate redundant assignment
Eliminate null pointer write warnings
Refactor: Replace malloc localifs with std::vector
Refactor: inline variable errors
Refactor: Localize scope of variable i