Entire stack/allocation system rewritten