Problem 8 solution with hacks, few things still to be implemented