Fix bugs in code for final push to github