Fixing the custom init script part.
Code failed due to scoping issue and sequence
Merged from upstream.