better error handling, removed dead comments,  version