fixes issue with incorrect delivieries
removes duplicate code in several controllers
Merge branch 'master' into statistics