introduced macros in SM
fixed two bugs