Modularise PAL code