Modified embed to expose arguments, and main part of code as functions and added __main__