Maybe change this to 

    require(isPowerOf2(initialCapacity), "Initial capacity must be power of 2")

and ditto for initialCapacity >= 1 << 30