That is an error generated by the MySQL server not the script itself. The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection.
You can read more about this problem and ask your host to increase the timeout if it is set too low. There can be other reasons as well. Here is a link that explains the error.
http://dev.mysql.com/doc/refman/5.0/en/gone-away.html
As for the index, probably I will look at it a little closer later today and add it into the 2.0 version if its not there already.