Improved Script building and serialization