Fixed lots of bugs with mod package parsing. Added unit tests to prevent regression.
Several bug fixes.