Memory optimisations to prevent crashing.