Added allocation pool, tests, fixed bugs