Made lots of change. Fixed some bugs too.