source code reorganization; global error state deprecated; bug fixes