Script fixes

Fixes #576, #577