More cleanup and scaffolding code for dynamic image allocation