Fix a few bugs while working with the code