Minor bugs fixing