Added defines and some initialisation code