Move macro code to classes