WIP: Implement dynamic memory allocation

TODO: Unit test for memory allocation