Minor upgrade 2. Fixing a lot of functions