Fixed lot of bugs