I am using a custom template to write my thesis, and I am trying to align the page headers on the right side and the page numbers on the left side, in odd pages. The template by default has the same alignment style for all pages (page headers on the top left and page numbers on the top right), as seen below:

I have succeeded in changing the alignment of the page numbers in odd pages using the code from this question:
\fancyhead[R]{\thepage\ifodd\value{page}\else\hfill\fi}
However, the header now overlaps with the page number in odd pages:
Could someone offer a hint/solution on how to move the page header to the top right, in odd pages only, so that it doesn't overlap with the page number? It must be something similar in syntax to the line above but I've been trying for a while with \leftmark and \rightmark and can't get it to work.
Many thanks in advance.
Edit: What seems to be causing the problem is that each chapter contained the \lhead{<Chapter header>} code, which is similar to \fancyhead[L]{<Chapter header>}. This is what is pushing the Chapter headers to the left all the time.
