Organise math_base a bit better and add shift/reflect functions.