Fixed a huge of bugs