Minor code clean up and adding onerror property