error callback fixes; code cleanup