Merge branch 'autopupfix' into 'master'

Added a number of fixes and optimizations

See merge request !423
3 jobs for master in 4 minutes and 55 seconds (queued for 5 seconds)