Implemented a  memory pool to be used in the future, to avoid reallocating too much, and added a few debug macros.