MIT License
removed integration, replaced with pre-calculated integrals
inlined some stuff