Fix wrong number of objects for version > 4
Cleaning
Add debug info for script
Fix regression with boxes with versions < 5