Fixed error about i not being incremented
Corrected many errors that prevent compile