Fixed Looping and other compiling errors.