Almost completely redesigned to improve thread
and support container limits.