improve configuration and validate to fail early. fix #17, fix #31