Remove threading for now. Improve error handling