Fix: fixed a numerical error problem with low read counts. Moved EM code
to separate module. Tried to make code more readable.