Fine-tune memory footprint calculation

Fixes #551