Some memory optimisations

Change-Id: I67b7e1b29750e65afc49b77754fb9db4f8834d92