sorted metadata and stack sizes

messy but working