Bug fixing and small changes