It's running... but only at 50% accuracy

I don't know, if the reason for that is k, which is set to 1, or if
something doesn't work in my code.
Anyway there is a lot of cleaning up I need to do.