Implemented a static optimiser, which works!