resolves #4; other bug fixes;