Fix some bugs, add validation to api responses