I refactored the code I wrote yesterday to reduce code duplication.  Also, where possible, analyze upload chunk sizes before we take them into the system rather than after.  This is more efficient and nominally more secure.