Fixed bugs before merging with master