Fix for infinite loop in wpstools #653