Fixed bug with empty regions causing bad_alloc exceptions.