Removed debug prints. Removed infinite loop in MySQL query.