Added calculation of inverse.
Reorganized methods.