abstract math implementation and split bc from handmade gf(2^8)

This makes everything a bit slower but should make the code base easier
to read and extend.

This also found out some errors and hardcoded constants.