[master] Fixed lots of bugs