minor changes and cleanup; separated stan code.