Fixed some bugs.

Should be working now