clean up, remove race conditions, improve exception messages