Compact the code by using imports for SIunits and constants.

Also make use of eps instead of some random 1e-6 number for
division by zero protection.