Fix batch of bugs