Bug fixes, write to external storage for test