Vast code reorganization; introduced custom exceptions; minor mods to documents