Replaced the macro with ensure_necessary_size().

Mainly done for transparency and many issues that were with it.
Improved ensure_necessary_size() a bit.