Add missing last_id++
Introduce possibility for crossbuilding
Fix up a few things.