This paper describes the implementation of a machine independent compiler designed to produce optimised source code for a higher level language. The advantages of optimising at the source rather than the machine code level are discussed. Optimisation techniques are set out in detail, paying particular attention to analysis of program structure and optimisation in the presence of flow.