Dulcimer,
it is difficult for any of us to just look at a piece of code and tell
where exactly things are going wrong. You'll have to learn to debug what
is happening in your case, and for this it is easiest if you make the
problem as simple as possible -- for example, use zero boundary values,
zero right hand sides, no hanging nodes, etc. You can then reduce the
amount of code that deal with each of these cases. This reduces the
number of possible sources of the problem.
From a cursory look at your code, I see that you are adding
contributions to the rhs vectors and the system matrix on each cell. But
I don't see that you set these vectors and the matrix to zero before
your loop over all cells. I may be missing this, but it seems like a bug.