basic loop updates

Just adding a local variable for array lengths. Also added a couple missing ;'s