Fix bug in APKG export

Options groups weren't getting exported properly due to incorrectly treating id as an integer.
Additionally, the cleanup of intermediate files/folders wasn't working