appPackager refactor (code broken down into functions, got rid of unnecessary commentaries)