Fixed some bugs. Not yet working.