Fixed commit changes from david as well as various bugs