Using promises for script constructor...

And some other bug fixes.