Updated and expanded functions to start building stack in memory

Needs to be split into multiple files later