Fixing various syntax errors

also fixed issue with points wrapping around the ends of the points array