Bug fixes for previous commit