Calculate application sizes correctly

Thanks to Pierre-Hugues Husson for looking at my code and finding out
that the application sizes were not being calculated properly!

Change-Id: I68af6a9e5d1b2b7e60c0409b55d8ee578e567a69
(cherry picked from commit 244241e358375b9e7203c0a90051fbc498d6f590)