Removed dependency to Javascript Math library from all functions; this results in a 25% speedup from preliminary tests