Removed unused include
Added commenting
Made panic more informative
Added math functions with correct commenting