Optimize declarations before deduplicating them (fixes #20)