IEEE 802.11ah, a new amendment to the Wi-Fi standard, adapts Wi-Fi networks to the emerging Internet of Things (IoT). A key component of .11ah is the Restricted Access Window (RAW), a new channel access mechanism, which reduces contention when even thousands of IoT devices operate in the same area by assigning them different channel times. This paper shows that existing studies incorrectly understand the RAW behavior, oversimplify its modeling and thereby overestimate the real system throughput in several times, especially for short durations of the reserved RAW slots. The core contribution of this paper is a new mathematical model based on a completely different approach, which yields more accurate results and thereby enables better IoT system dimensioning. The developed model is suitable for many scenarios typical for IoT. It allows finding RAW parameters that optimize system performance in terms of throughput, power consumption, and packet loss ratio. The proposed solution is can be used for various traffic patterns: when each device transmits a single packet, a batch of packets of random size, or it has full-buffer traffic.