I still need to fix the safeDiv, but the rest works fine