Fixed couple of bugs