Bugs fixing and improvements