Minor fixes and added the theard option