Fix header margin top when keyboard is shown and fixed memory leaks