Solved a couple of bugs