STILL UNTESTED. Fixing some obvious errors