Fixing a number of issues