Scripts refactoring and doc update