fixed socket closing on stdout.close() call (used in system())
moved registered macros to the shell's context
moved recording macros to the shell's context