updates according to comments and fixes bugs

references #7