Multiple bugs fixing