Refactor kazmath extensions to separate source file, add to internal API