Generified Hiero code, now more secure and shorter

Also removed some unnecessary boxing of primitives, unused variables and ran a formatter on all of it. All done carefully, but I didn't compile test it. Should be fine though.