refactored package structure; improved error messages