Optimise code and layout